package com.aistar.mapper;

import com.aistar.model.entity.Education;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface EducationMapper {
    //根据resumeId获取教育经历
    @Select("select * from education where resume_id = #{resumeId} ")
    List<Education> findByResumeId(Integer resumeId);

    //根据id获取教育经历信息
    @Select("select * from education where id = #{id}")
    Education findById(Integer id);

    //根据resumeId获取id
    @Select("select id from education where resume_id = #{resumeId}")
    List<Integer> findIdByResumeId(Integer resumeId);

    //更新教育经历
    @Update("update education set school_name=#{schoolName},degree=#{degree},major=#{major},start_date=#{startDate},end_date=#{endDate},experience_school=#{experienceSchool} where id = #{id}")
    Integer updateEducation(Education education);

    //添加教育经历信息
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into education(school_name,degree,major,start_date,end_date,experience_school,resume_id) values(#{schoolName},#{degree},#{major},#{startDate},#{endDate},#{experienceSchool},#{resumeId})")
    Integer insertEducation(Education education);


    //删除简历的所有实习经历
    @Delete("delete from education where resume_id = #{resumeId}")
    Integer deleteEducationByResumeId(Integer resumeId);

    // 根据教育经历id删除教育经历
    @Delete("delete from education where id = #{id}")
    Integer deleteEducationById(Integer id);
}
